/**
 * Comment组件
 * 
 * @author GaoYoubo
 * @since 2013-06-26
 */
if (typeof (mlog) === "undefined") {
	var mlog = function() {
	}
};
var MCMT = mlog.comment = {};
var d = document,
w = window,
p = parseInt,
dd = d.documentElement,
db = d.body,
dc = d.compatMode == 'CSS1Compat',
dx = dc ? dd: db,
ec = encodeURIComponent,
params = {},
ua = navigator.userAgent.toLowerCase(),
iopa = ua.indexOf('opera') != -1 && opera.version(),
iie = (ua.indexOf('msie') != -1 && !iopa) && ua.substr(ua.indexOf('msie') + 5, 3),
s = d.getElementsByTagName('script'),
v = mlog.variable;
$.extend(mlog.comment, {
	conf : {
		formbox: 'mlog-comment-form',
		listbox: 'mlog-comment-list',
		form_url : v.base + '/plugin/comment/form',
		add_url : v.base + '/plugin/comment/add',
		list_url : v.base + '/plugin/comment/list',
		msgShow : true,							//是否允许显示消息
		maxlength: 140,                         //最长评论字数
	},
	
	lang : {
		iptCmt : '请输入你的评论',
		content : '请输入评论内容',
		fkey : '评论框配置错误，请确认参数f_key是否正确配置',
		ftype : '评论框配置错误，请确认参数f_type是否正确配置',
		maxlength: '评论字数超出限制',
		toUser : '评论失败，无法确定toUser参数',
	},
	
	em : {
		df: [{"id":"14", "phrase":"微笑", "url":"default/14.gif"},{"id":"1", "phrase":"撇嘴", "url":"default/1.gif"},{"id":"2", "phrase":"色", "url":"default/2.gif"},{"id":"3", "phrase":"发呆", "url":"default/3.gif"},{"id":"4", "phrase":"得意", "url":"default/4.gif"},{"id":"5", "phrase":"流泪", "url":"default/5.gif"},{"id":"6", "phrase":"害羞", "url":"default/6.gif"},{"id":"7", "phrase":"闭嘴", "url":"default/7.gif"},{"id":"8", "phrase":"睡", "url":"default/8.gif"},{"id":"9", "phrase":"大哭", "url":"default/9.gif"},{"id":"10", "phrase":"尴尬", "url":"default/10.gif"},{"id":"11", "phrase":"发怒", "url":"default/11.gif"},{"id":"12", "phrase":"调皮", "url":"default/12.gif"},{"id":"13", "phrase":"呲牙", "url":"default/13.gif"},{"id":"0", "phrase":"惊讶", "url":"default/0.gif"},{"id":"15", "phrase":"难过", "url":"default/15.gif"},{"id":"16", "phrase":"酷", "url":"default/16.gif"},{"id":"96", "phrase":"冷汗", "url":"default/96.gif"},{"id":"18", "phrase":"抓狂", "url":"default/18.gif"},{"id":"19", "phrase":"吐", "url":"default/19.gif"},{"id":"20", "phrase":"偷笑", "url":"default/20.gif"},{"id":"21", "phrase":"可爱", "url":"default/21.gif"},{"id":"22", "phrase":"白眼", "url":"default/22.gif"},{"id":"23", "phrase":"傲慢", "url":"default/23.gif"},{"id":"24", "phrase":"饥饿", "url":"default/24.gif"},{"id":"25", "phrase":"困", "url":"default/25.gif"},{"id":"26", "phrase":"惊恐", "url":"default/26.gif"},{"id":"27", "phrase":"流汗", "url":"default/27.gif"},{"id":"28", "phrase":"憨笑", "url":"default/28.gif"},{"id":"29", "phrase":"大兵", "url":"default/29.gif"},{"id":"30", "phrase":"奋斗", "url":"default/30.gif"},{"id":"31", "phrase":"咒骂", "url":"default/31.gif"},{"id":"32", "phrase":"疑问", "url":"default/32.gif"},{"id":"33", "phrase":"嘘", "url":"default/33.gif"},{"id":"34", "phrase":"晕", "url":"default/34.gif"},{"id":"35", "phrase":"折磨", "url":"default/35.gif"},{"id":"36", "phrase":"衰", "url":"default/36.gif"},{"id":"37", "phrase":"骷髅", "url":"default/37.gif"},{"id":"38", "phrase":"敲打", "url":"default/38.gif"},{"id":"39", "phrase":"再见", "url":"default/39.gif"},{"id":"97", "phrase":"擦汗", "url":"default/97.gif"},{"id":"98", "phrase":"抠鼻", "url":"default/98.gif"},{"id":"99", "phrase":"鼓掌", "url":"default/99.gif"},{"id":"100", "phrase":"糗大了", "url":"default/100.gif"},{"id":"101", "phrase":"坏笑", "url":"default/101.gif"},{"id":"102", "phrase":"左哼哼", "url":"default/102.gif"},{"id":"103", "phrase":"右哼哼", "url":"default/103.gif"},{"id":"104", "phrase":"哈欠", "url":"default/104.gif"},{"id":"105", "phrase":"鄙视", "url":"default/105.gif"},{"id":"106", "phrase":"委屈", "url":"default/106.gif"},{"id":"107", "phrase":"快哭了", "url":"default/107.gif"},{"id":"108", "phrase":"阴险", "url":"default/108.gif"},{"id":"109", "phrase":"亲亲", "url":"default/109.gif"},{"id":"110", "phrase":"吓", "url":"default/110.gif"},{"id":"111", "phrase":"可怜", "url":"default/111.gif"},{"id":"112", "phrase":"菜刀", "url":"default/112.gif"},{"id":"89", "phrase":"西瓜", "url":"default/89.gif"},{"id":"113", "phrase":"啤酒", "url":"default/113.gif"},{"id":"114", "phrase":"篮球", "url":"default/114.gif"},{"id":"115", "phrase":"乒乓", "url":"default/115.gif"},{"id":"60", "phrase":"咖啡", "url":"default/60.gif"},{"id":"61", "phrase":"饭", "url":"default/61.gif"},{"id":"46", "phrase":"猪头", "url":"default/46.gif"},{"id":"63", "phrase":"玫瑰", "url":"default/63.gif"},{"id":"64", "phrase":"凋谢", "url":"default/64.gif"},{"id":"116", "phrase":"示爱", "url":"default/116.gif"},{"id":"66", "phrase":"爱心", "url":"default/66.gif"},{"id":"67", "phrase":"心碎", "url":"default/67.gif"},{"id":"53", "phrase":"蛋糕", "url":"default/53.gif"},{"id":"54", "phrase":"闪电", "url":"default/54.gif"},{"id":"55", "phrase":"炸弹", "url":"default/55.gif"},{"id":"56", "phrase":"刀", "url":"default/56.gif"},{"id":"57", "phrase":"足球", "url":"default/57.gif"},{"id":"117", "phrase":"瓢虫", "url":"default/117.gif"},{"id":"59", "phrase":"便便", "url":"default/59.gif"},{"id":"75", "phrase":"月亮", "url":"default/75.gif"},{"id":"74", "phrase":"太阳", "url":"default/74.gif"},{"id":"69", "phrase":"礼物", "url":"default/69.gif"},{"id":"49", "phrase":"拥抱", "url":"default/49.gif"},{"id":"76", "phrase":"强", "url":"default/76.gif"},{"id":"77", "phrase":"弱", "url":"default/77.gif"},{"id":"78", "phrase":"握手", "url":"default/78.gif"},{"id":"79", "phrase":"胜利", "url":"default/79.gif"},{"id":"118", "phrase":"抱拳", "url":"default/118.gif"},{"id":"119", "phrase":"勾引", "url":"default/119.gif"},{"id":"120", "phrase":"拳头", "url":"default/120.gif"},{"id":"121", "phrase":"差劲", "url":"default/121.gif"},{"id":"122", "phrase":"爱你", "url":"default/122.gif"},{"id":"123", "phrase":"NO", "url":"default/123.gif"},{"id":"124", "phrase":"OK", "url":"default/124.gif"},{"id":"42", "phrase":"爱情", "url":"default/42.gif"},{"id":"85", "phrase":"飞吻", "url":"default/85.gif"},{"id":"43", "phrase":"跳跳", "url":"default/43.gif"},{"id":"41", "phrase":"发抖", "url":"default/41.gif"},{"id":"86", "phrase":"怄火", "url":"default/86.gif"},{"id":"125", "phrase":"转圈", "url":"default/125.gif"},{"id":"126", "phrase":"磕头", "url":"default/126.gif"},{"id":"127", "phrase":"回头", "url":"default/127.gif"},{"id":"128", "phrase":"跳绳", "url":"default/128.gif"},{"id":"129", "phrase":"挥手", "url":"default/129.gif"},{"id":"130", "phrase":"激动", "url":"default/130.gif"},{"id":"131", "phrase":"街舞", "url":"default/131.gif"},{"id":"132", "phrase":"献吻", "url":"default/132.gif"},{"id":"133", "phrase":"左太极", "url":"default/133.gif"},{"id":"134", "phrase":"右太极", "url":"default/134.gif"}],
	},
	
	
	UI : function(){
		MCMT.loadForm()
		MCMT.loadList();
	},
	
	loadForm : function(){
		var formbox = d.getElementById(MCMT.conf.formbox);
		if(!formbox) return;
		$.get(mlog.comment.conf.form_url, function(response){
			formbox.innerHTML = response;
			formbox.focus();
			MCMT.shoIntro(formbox);
			$('#m_tts').html(MCMT.conf.maxlength);
		});
	},
	
	loadList : function(page){
		var listbox = d.getElementById(MCMT.conf.listbox);
		if(!listbox) return;
		if(!page) page = 1;
		$.get(MCMT.conf.list_url, {fkey: MCMT.conf.fkey, ftype: MCMT.conf.ftype, page: page}, function(response){
			listbox.innerHTML = MCMT.resovleFace(response);
		});
	},
	
	/**
	 * 解析表情
	 */
	resovleFace : function(s){
		if(typeof (s) != "undefined") {
			var sArr = s.match(/\[.*?\]/g);
			if(sArr){
				for(var i = 0; i < sArr.length; i++){
					for(var j = 0; j < MCMT.em.df.length; j++){
						if('[' + MCMT.em.df[j].phrase + ']' === sArr[i]){
							var reStr = "<img src=\"" + v.base + "/images/em/" + MCMT.em.df[j].url + "\" height=\"22\" width=\"22\" />";
							s = s.replace(sArr[i], reStr);
						}
					}
				}
			}
		}
		return s;
	},
	
	hidIntro: function (e) {
		if (e.value == MCMT.lang.iptCmt) {
			e.value = '';
			$(e).css('color', '#272727');
		} else {
			$(e).css('color', '#272727');
		}
	},
	
	shoIntro: function (e) {
		if (!e.value) {
			//e.value = MCMT.lang.iptCmt;
			e.style.color = '#BDBBBB';
		}
	},
	
	checkTxt: function (txt, suf) {
		console.log(MCMT.conf.formbox)
		console.log(MCMT.conf.maxlength);
		var s = d.getElementById('m_tts' + (suf != null ? '_' + suf: '')),
		cc = d.getElementById('m_cmt_cnt' + (suf != null ? '_' + suf: '')),
		sc,
		ch,
		k = txt.value.match(/[^\x00-\xff]/g),
		f = Math.floor((MCMT.conf.maxlength * 2 - txt.value.length - (k && k.length || 0)) / 2);
		if (f >= 0) {
			s.innerHTML = f;
			s.style.color = ''
		} else {
			if (MCMT.conf.maxlength == 0) {
				s.innerHTML = Math.abs(f);
				s.style.color = ''
			} else {
				s.innerHTML = -Math.abs(f);
				s.style.color = '#FF7878'
			}
		}
		cc.innerHTML = txt.value;
		sc = MCMT.getWH(cc),
		//ch = Math.max(MCMT.conf.style == 'side' || MCMT.conf.style == 'facebook' || MCMT.conf.style == 'color' ? 40 : 60, sc.oH + 18);
		ch = sc.oH + 18;
		txt.style.height = ch + 'px';
		txt.parentNode.style.height = ch + 'px';
		txt.parentNode.parentNode.parentNode.style.height = ch + 18 + 'px';
		return p(s.innerHTML)
	},
	
	/**
	 * 显示/隐藏表情库
	 * @param p当前页
	 * @param s每页数量
	 */
	showSmile: function(p, s, suf){
		var flag = true;
		if(!p){p = 1; flag = false;}
		if(!s){s = 50;}
		
		//加载分页
		MCMT.loadSmilePages(p, s, suf);
		//加载表情
		MCMT.loadSmiles(p, s, suf);
		//显示表情
		//$('#m_ssmile' + (suf ? '_' + suf : '')).css('display', 'block');
		var display = $('#m_ssmile' + (suf ? '_' + suf : '')).css('display');
		if(display == 'none'){
			$('#m_ssmile' + (suf ? '_' + suf : '')).fadeIn();
		}
		else {
			if(!flag){
				$('#m_ssmile' + (suf ? '_' + suf : '')).fadeOut();
			}
		}
		
	},
	
	/**
	 * 加载分页
	 * @param p当前页
	 * @param s每页数量
	 */
	loadSmilePages : function(p, s, suf){
		if(!p){p = 1;}
		if(!s){s = 50;}
		var totalPage = MCMT.em.df.length / s;
        if (MCMT.em.df.length % s > 0) {
        	totalPage += 1;
        }
        var page_html = new Array();
        for(var i = 1; i <= totalPage; i++){
        	page_html[i - 1] = '<li onclick="MCMT.showSmile(' + i + ', ' + s + ', ' + suf + ');" style="' + (p == i ? 'background-color:#d3e4f0;' : '') + 'border: 1px solid #d3e4f0;float: left; list-style: none; line-height: 20px; width: 20px; height: 20px; overflow: hidden; text-align: center; margin: 0px 2px; display: inline; cursor: pointer; padding: 0px;">' + i + '</li>';
        }
        $('#m_ssmile_page' + (suf ? '_' + suf : '')).html(page_html.join(''));
	},
	
	/**
	 * 分页加载表情
	 * @param p当前页
	 * @param s每页数量
	 */
	loadSmiles : function(p, s, suf){
		if(!p){p = 1;}
		if(!s){s = 50;}
		
		var startIndex = (p - 1) * s;
		var endIndex = (startIndex + s) > MCMT.em.df.length ? MCMT.em.df.length : (startIndex + s);
		
		var em_html = new Array();
		for(var i = startIndex; i < endIndex; i++){
			var phrase = MCMT.em.df[i].phrase;
			var url = mlog.variable.base + '/images/em/' + MCMT.em.df[i].url;
			em_html[i] = '<li style="list-style: none; border: 1px solid #d3e4f0; border-top: 1px solid #fff; border-left: 1px solid #fff; width: 29px; height: 29px; overflow: hidden; float: left; background: none repeat scroll 0 center transparent; margin: 0; padding: 0;"><img onclick="MCMT.addSmile(this, ' + suf + ');" style="cursor: pointer; display: block; margin: 4px auto 0;" title="' + phrase + '" src="' + url + '"></li>\n';
		}
		//em_html[em_html.length] = '<div style="clear: both"></div>';
		$('#m_ssmile_list' + (suf ? '_' + suf : '')).html(em_html.join(''));
	},
	
	/**
	 * 插入表情
	 */
	addSmile : function(o, suf){
		var txtid = 'm_comment' + (suf ? '_' + suf : '');
		d.getElementById(txtid).focus();
		var smile = '[' + $(o).attr('title') + ']';
		MCMT.insertContent(txtid, smile);
		//隐藏表情
		//$('#m_ssmile' + (suf ? '_' + suf : '')).css('display', 'none');
		$('#m_ssmile' + (suf ? '_' + suf : '')).fadeOut();
	},
	
	
	/**
	 * 添加评论
	 * @param btn 按钮对象
	 * @param suf 后缀
	 */
	addCmt: function(btn, suf){
		var tts = d.getElementById('m_tts' + (suf ? '_' + suf : ''));
		var content = $('#m_comment' + (suf ? '_' + suf : '')).val();
		var parent = null;
		if(suf) {
			parent = $('#mcmt_parent_' + suf).val();
		}
		if(!MCMT.conf.toUser){
			MCMT.showMsg(tts, MCMT.lang.toUser, '#FF7878', '12px');
			return;
		}
		if(!MCMT.conf.fkey){
			MCMT.showMsg(tts, MCMT.lang.fkey, '#FF7878', '12px');
			return;
		}
		if(!MCMT.conf.ftype){
			MCMT.showMsg(tts, MCMT.lang.ftype, '#FF7878', '12px');
			return;
		}
		if(!content || MCMT.trim(content) == '' || content == MCMT.lang.iptCmt){
			MCMT.showMsg(tts, MCMT.lang.content, '#FF7878', '12px');
			return;
		}
		if($('#m_tts').html() < 0){
			MCMT.showMsg(tts, MCMT.lang.maxlength, '#FF7878', '12px');
			return;
		}
		$(btn).addClass('m_cmt_btn_disabled');
		btn.innerHTML = '发布中';
		$.post(
			MCMT.conf.add_url, 
			{fkey: MCMT.conf.fkey, ftype: MCMT.conf.ftype, toUser: MCMT.conf.toUser, content: content, parent : parent}, 
			function(response){
				if(response.success == true){
					MCMT.showMsg(tts, response.message, '#FF7878', '12px');
					$('#m_comment').val('');
					MCMT.loadList();
				}
				else {
					MCMT.showMsg(tts, response.message, '#FF7878', '12px');
				}
				$(btn).removeClass('m_cmt_btn_disabled');
				btn.innerHTML = '发&nbsp;&nbsp;布';
			}
		);
	},
	
	/**
	 * 回复
	 */
	addRpy: function(a, b){
		//try {
			var f = d.getElementById('m_cmt_' + a);
			var cu = d.getElementById('m_cmt_uname_' + a);
			var r = d.getElementById('m_rpy');
			var ri = d.getElementById('m_rpy_' + a);
			var A = '<div id="m_rpy_' + a + '" style="padding-left: 60px; padding-top: 10px;">';
			if (ri != null) {
				f.removeChild(ri)
			} else {
				f.innerHTML = 
					f.innerHTML + A + 
					r.innerHTML.replace('m_comment_region', a + (b != null ? ', ' + b: ''))
					.replace('m_comment', 'm_comment_' + a)
					.replace('m_cmt_cnt', 'm_cmt_cnt_' + a)
					.replace('m_cmt_btn', 'm_cmt_btn_' + a)
					.replace(/m_tts_region/g, a)
					.replace('m_tts', 'm_tts_' + a)
					.replace(/m_smile_region/g, a)
					.replace('m_ssmile_id', 'm_ssmile_' + a)
					.replace(/m_ssmile_page_region/g, a)
					.replace('m_ssmile_page_id', 'm_ssmile_page_' + a)
					.replace(/m_ssmile_list_region/g, a)
					.replace('m_ssmile_list_id', 'm_ssmile_list_' + a)
					.replace(/mcmt_suf/g, a)
					.replace('m_comment_at', '@' + cu.innerHTML + ': ')
					.replace(/mcmt_maxlength/g, MCMT.conf.maxlength)
					
					//设置Parent评论
					.replace('mcmt_parent_id', 'mcmt_parent_' + a)
					.replace('mcmt_parent_value', a)
					+ '</div>';
				var c = d.getElementById('m_comment_' + a);
				if(c){
					c.focus();
					MCMT.moveEnd(c);
				}
				//c.value = '';
			}
		//} catch(e) {}
	},
	
	//textarea光标位置插入内容
	insertContent : function(inputId, content){
		if(!inputId || !content){return;}
		var inputObj = document.getElementById(inputId);
		if(!inputObj){return;}
		
		//inputObj.focus();
		
		//IE support
	    if (document.selection) {
	        inputObj.focus();
	        sel = document.selection.createRange();
	        sel.text = content;
	        sel.select();
	    }
	    //MOZILLA/NETSCAPE support
	    else if (inputObj.selectionStart || inputObj.selectionStart == '0') {
	    	var startPos = inputObj.selectionStart;
	        var endPos = inputObj.selectionEnd;
	        // save scrollTop before insert
	        var restoreTop = inputObj.scrollTop;
	        inputObj.value = inputObj.value.substring(0, startPos) + content + inputObj.value.substring(endPos, inputObj.value.length);
	        if (restoreTop > 0) {
	        	inputObj.scrollTop = restoreTop;
	        }
	        inputObj.focus();
	        inputObj.selectionStart = startPos + content.length;
	        inputObj.selectionEnd = startPos + content.length;
		} else {
			inputObj.value += content;
			inputObj.focus();
		}
	},
	
	//textarea光标移动到最后
	moveEnd: function(obj){
	    obj.focus();
	    var len = obj.value.length;
	    if (document.selection) {
	        var sel = obj.createTextRange();
	        sel.moveStart('character',len);
	        sel.collapse();
			sel.select();
		} else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
			obj.selectionStart = obj.selectionEnd = len; 
	    } 
	},
	
	noUface: function (e, u) {
		e.onerror = function () {};
		if (u != null && u != '') {
			e.src = u
		}
	},
	loadUface: function (e, u, d) {
		if (u != null && d != null && u != '' && d != '') {
			setTimeout(function () {
				e.src = u
			},
			1000)
		}
		e.onload = function () {};
		e.onerror = function () {
			MCMT.noUface(e, d)
		}
	},
	
	isKeyTrigger : function(e, keyCode){
		var argv = MCMT.isKeyTrigger.arguments;
	    var argc = MCMT.isKeyTrigger.arguments.length;
	    var bCtrl = false;
	    if(argc > 2){
	    	bCtrl = argv[2];
	    }
	    var bAlt = false;
	    if(argc > 3){
	        bAlt = argv[3];
	    }

	    var nav4 = window.Event ? true : false;

	    if(typeof e == 'undefined') {
	        e = event;
	    }

	    if(bCtrl &&
	        !((typeof e.ctrlKey != 'undefined') ? e.ctrlKey : e.modifiers & Event.CONTROL_MASK > 0)){
	        return false;
	    }
	    if( bAlt &&
	        !((typeof e.altKey != 'undefined') ? e.altKey : e.modifiers & Event.ALT_MASK > 0)){
	        return false;
	    }
	    var whichCode = 0;
	    if (nav4) 
	    	whichCode = e.which;
	    else if (e.type == "keypress" || e.type == "keydown")
	        whichCode = e.keyCode;
	    else 
	    	whichCode = e.button;
	    return (whichCode == keyCode);
	},
	
	ctrlEnter : function(e, suf){
	    //var ie = navigator.appName=="Microsoft Internet Explorer" ? true : false;
		var ie = (document.all) ? true : false; 
		var btn = suf ? d.getElementById('m_cmt_btn_' + suf) : d.getElementById('m_cmt_btn');
	    if(ie){
	        if(event.ctrlKey && window.event.keyCode==13){
	        	MCMT.addCmt(btn);
	        }
	    }else{
	        if(MCMT.isKeyTrigger(e,13,true)){
	        	MCMT.addCmt(btn);
	        }
	    }
	},
	
	/**
	 * 获取对象的高度
	 */
	getWH: function (e) {
		var r = new Array();
		r.sW = dx.clientWidth;
		r.sH = dx.clientHeight;
		if (typeof(e) == 'object') {
			r.psW = (dx.scrollLeft == 0 ? db.scrollLeft: dx.scrollLeft) + dx.clientWidth / 2 - e.clientWidth / 2;
			r.psH = (dx.scrollTop == 0 ? db.scrollTop: dx.scrollTop) + dx.clientHeight / 2 - e.clientHeight / 2;
			r.oW = e.clientWidth;
			r.oH = e.clientHeight
		}
		return r
	},
	
	/**
	 * 获取Y
	 */
	getY: function () {
		var y = 0;
		if (typeof(w.pageYOffset) == 'number') {
			y = w.pageYOffset
		} else if (db && (db.scrollLeft || db.scrollTop)) {
			y = db.scrollTop
		} else if (dd && (dd.scrollLeft || dd.scrollTop)) {
			y = dd.scrollTop
		}
		return y
	},
	
	mouseOO: function (e, t) {
		if (e.id.indexOf('m_smile') != -1) {
			if (t == 'on') {
				e.style.background = 'url("' + v.base + '/images/mcmt/emotion2.png") no-repeat 0 -16px'
			} else {
				e.style.background = 'url("' + v.base + '/images/mcmt/emotion2.png") no-repeat'
			}
		} else {
			e.style.background = e.style.background.replace(/\/\w+\.png/g, '/' + t)
		}
	},
	
	
	/**
	 * 显示消息
	 */
	showMsg: function (e, msg, color, fontsize) {
		if (MCMT.conf.msgShow == true) {
			MCMT.conf.msgShow = false;
			var d = e.type == 'textarea' ? e.value: e.innerHTML,
			ec = e.style.color,
			es = e.style.fontSize;
			if (e.type == 'textarea') {
				e.value = msg
			} else {
				e.innerHTML = msg
			}
			e.style.color = color;
			e.style.fontSize = fontsize;
			setTimeout(function () {
				e.style.color = ec;
				e.style.fontSize = es;
				if (e.type == 'textarea') {
					e.value = d
				} else {
					e.innerHTML = d
				}
				MCMT.conf.msgShow = true
			},
			2000)
		}
	},
	
	cagBtn: function (t, e) {
		if (t == 'on') {
			e.style.background = 'url("' + v.base + '/images/mcmt/buttonLarge.png") repeat-x scroll 0 -28px transparent'
		} else if (t == 'out') {
			e.style.background = 'url("' + v.base + '/images/mcmt/buttonLarge.png") repeat-x scroll 0 0 transparent'
		}
	},
	
	trim: function (s) {
		return s.replace(/(^\s*)|(\s*$)/g, '')
	},
});